package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EvNotice;
import com.ruoyi.system.service.IEvNoticeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通知与公告Controller
 * 
 * @author wtd1
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/system/noticeofwtd")
public class EvNoticeController extends BaseController
{
    @Autowired
    private IEvNoticeService evNoticeService;

    /**
     * 查询通知与公告列表
     */
    @PreAuthorize("@ss.hasPermi('system:noticeofwtd:list')")
    @GetMapping("/list")
    public TableDataInfo list(EvNotice evNotice)
    {
        startPage();
        List<EvNotice> list = evNoticeService.selectEvNoticeList(evNotice);
        return getDataTable(list);
    }

    /**
     * 导出通知与公告列表
     */
    @PreAuthorize("@ss.hasPermi('system:noticeofwtd:export')")
    @Log(title = "通知与公告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EvNotice evNotice)
    {
        List<EvNotice> list = evNoticeService.selectEvNoticeList(evNotice);
        ExcelUtil<EvNotice> util = new ExcelUtil<EvNotice>(EvNotice.class);
        util.exportExcel(response, list, "通知与公告数据");
    }

    /**
     * 获取通知与公告详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:noticeofwtd:query')")
    @GetMapping(value = "/{noticeId}")
    public AjaxResult getInfo(@PathVariable("noticeId") Long noticeId)
    {
        return success(evNoticeService.selectEvNoticeByNoticeId(noticeId));
    }

    /**
     * 新增通知与公告
     */
    @PreAuthorize("@ss.hasPermi('system:noticeofwtd:add')")
    @Log(title = "通知与公告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EvNotice evNotice)
    {
        return toAjax(evNoticeService.insertEvNotice(evNotice));
    }

    /**
     * 修改通知与公告
     */
    @PreAuthorize("@ss.hasPermi('system:noticeofwtd:edit')")
    @Log(title = "通知与公告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EvNotice evNotice)
    {
        return toAjax(evNoticeService.updateEvNotice(evNotice));
    }

    /**
     * 删除通知与公告
     */
    @PreAuthorize("@ss.hasPermi('system:noticeofwtd:remove')")
    @Log(title = "通知与公告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noticeIds}")
    public AjaxResult remove(@PathVariable Long[] noticeIds)
    {
        return toAjax(evNoticeService.deleteEvNoticeByNoticeIds(noticeIds));
    }
}
